﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ERPStudio;
using System.Data.SqlClient;

namespace ResUma
{
    public partial class SetariLunareFrm : FrmRezumat
    {
        Int16 anul = 0;
        public SetariLunareFrm(ModuleClass mc,Int16 _anul):base(mc)
        {
            InitializeComponent();
            workConnString = "ESRPConnectionString";
            anul = _anul;
            eSRPDataSet.resuma_SetariLuna.AnulColumn.DefaultValue = anul;
        }

        private void SetariLunareFrm_Load(object sender, EventArgs e)
        {
            AddBindingSource(this.resuma_SetariLunaBindingSource);
            listTableAdaptor.Add(resuma_SetariLunaTableAdapter.Adapter);

            SqlConnection con = DeschideConexiune(workConnString);
            this.resuma_SetariLunaTableAdapter.Connection = con;
            this.resuma_SetariLunaTableAdapter.FillByAnul(this.eSRPDataSet.resuma_SetariLuna,anul);
            InchideConexiune(con);
        }

        private void resuma_SetariLunaDataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            if(e.ColumnIndex==lunaColumn.Index)
                if (Convert.ToInt16(e.FormattedValue) > 12 || (Convert.ToInt16(e.FormattedValue) < 1))
                {
                    MessageBox.Show("Luna poate fi un numar intreg intre 1 si 12!");
                    e.Cancel = true;
                    return;
                }
            if (e.ColumnIndex == anulColumn.Index)
                if (Convert.ToInt16(e.FormattedValue) > 2100 || (Convert.ToInt16(e.FormattedValue) < 2000))
                {
                    MessageBox.Show("Anul poate fi un numar intreg intre 2000 si 2100!");
                    e.Cancel = true;
                    return;
                }
            if (e.ColumnIndex == zileColumn.Index)
                if (Convert.ToInt16(e.FormattedValue) > 31 || (Convert.ToInt16(e.FormattedValue) < 1))
                {
                    MessageBox.Show("Anul poate fi un numar intreg intre 1 si 31!");
                    e.Cancel = true;
                    return;
                }

            
        }
    }
}
